package com.jzk.cloudshop.portalorderapi.web;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.jzk.cloudshop.common.dto.GoodsDto;
import com.jzk.cloudshop.common.pojo.Order;
import com.jzk.cloudshop.portalorderapi.remote.OrderServiceRemote;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api("order api")
@RestController
@RequestMapping("/orders")
class OrderApiController {

	protected static final Logger logger = LoggerFactory.getLogger(OrderApiController.class);
	
	@Autowired
	private OrderServiceRemote orderServiceRemote;
		
	@ApiOperation(value="根据商品Id获取商品信息", notes="")
    @RequestMapping(value={"/{orderId}"}, method=RequestMethod.GET)
    public String getOrderById(@PathVariable(value = "orderId") Long orderId) {
        return orderServiceRemote.getOrderById(orderId);
    }
	
	@ApiOperation(value="创建新订单", notes="")
	@RequestMapping(value={"/createNewOrder"}, method=RequestMethod.POST)
	public Order createNewOrder(List<GoodsDto> goodsList) {
		Order order = null;
		//TODO:到数据库新增订单和订单明细
		order = new Order();
		return order;
	}
	
	@ApiOperation(value="现金支付订单", notes="")
	@RequestMapping(value={"/payForCash"}, method=RequestMethod.POST)
	public String payForCash(String orderNo) {
		//TODO:更新订单状态，支付状态，支付方式
		return null;
	}

}